<?php
class Seller extends CS_Controller{
    
    function _init(){
        $this->load->helper(array('common'));
        $this->load->library('pagination');
        $this->load->model('order_base_model', 'order_base');
    }
    
    function index($pg = 1){
        $data['bit_wan']   = $this->input->get('bit_wan') ? $this->input->get('bit_wan') : 16;
        $getData = $data;
        $num = ($pg-1)*20;
        $config['base_url'] = base_url('seller/index');
        $config['total_rows'] = $this->order_base->userSellerTotal($getData);
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $data['pg_link'] = $this->pagination->create_links();
        $data['resultObj'] = $this->order_base->findUserSeller($num, $getData);
        $data['all_rows'] = $config['total_rows'];
        $data['pg_now'] = $pg;
        $this->load->view('seller/index', $data);
    }
    
    public function search($pg = 1)
    {
        if (!$this->search_get_validate($this->input->get())) {
            $this->redirect('member/index');
        }
        $data['startDate'] = $this->input->get('startDate');
        $data['endDate']   = $this->input->get('endDate');
        $data['userName']  = $this->input->get('userName');
        $data['bit_wan']   = $this->input->get('bit_wan') ? $this->input->get('bit_wan') : 16;
        $getData = $data;
       
        $num = ($pg-1)*20;
        $config['first_url'] = base_url('seller/search').$this->pageGetParam($this->input->get());
        $config['suffix'] = $this->pageGetParam($this->input->get());
        $config['base_url']    = base_url('seller/search');
        $config['total_rows']  = $this->order_base->userSellerTotal($getData);
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $data['pg_link']   = $this->pagination->create_links();
        $data['resultObj'] = $this->order_base->findUserSeller($num, $getData);
        $data['all_rows']  = $config['total_rows'];
        $data['pg_now']    = $pg;
        $this->load->view('seller/index', $data);
    }
    
    public function detail($pg = 1){
        if (!$this->search_get_validate($this->input->get())) {
            $this->redirect('member/detail');
        }
        $data['startDate'] = $this->input->get('startDate');
        $data['endDate']   = $this->input->get('endDate');
        $data['userName']  = $this->input->get('userName');
        $data['bit_wan']  = $this->input->get('bit_wan') ? $this->input->get('bit_wan') : 16;
        $getData = $data;
        $num = ($pg-1)*20;
        $config['first_url'] = base_url('seller/detail').$this->pageGetParam($this->input->get());
        $config['suffix'] = $this->pageGetParam($this->input->get());
        $config['base_url']    = base_url('seller/detail');
        $config['total_rows']  = $this->order_base->userSellerDetailsTotal($getData);
        $config['uri_segment'] = 3;
        $this->pagination->initialize($config);
        $data['pg_link']   = $this->pagination->create_links();
        $data['resultObj'] = $this->order_base->findUserSellerDetails($num, $getData);
        $data['all_rows']  = $config['total_rows'];
        $data['pg_now']    = $pg;
        $this->load->view('seller/detail', $data);
    }
    
}